<template>
  <div>
    <input type="text" v-model.number="age1" />
    <input type="text" placeholder="明年的年龄" v-model="next" />
  </div>
</template>

<script>
export default {
  data() {
    return {
      age1: '',
    }
  },
  computed: {
    next: {
      get() {
        return this.age1 + 1
      },
      //修改计算属性的值的时候会触发set
      set(newValue) {
        //获取到的值，就是修改的最新的值
        console.log(newValue)
        this.age1 = newValue - 1
      },
    },
  },
}
</script>

<style></style>
